<% @page_title = "多背一公斤 | 照片分享" %>

<% content_for(:sidebar) do %>
  <h4><%= link_to "回到照片分享", photos_url %></h4>
<% end %>

<h3><%= @photo.title %></h3>
<div>
	<span class="tip">由</span> <%= link_to @photo.user.login, user_path(@photo.user.id) %> <span class="tip">分享于 <%= show_date @photo.created_at %></span>
</div>
<div>
<% if @photo.event -%>
  <p>这张照片分享到了 <%= link_to @photo.event.title, event_path(@photo.event.id) %> 活动中</p>
<% end -%>
<% if @photo.school -%>
  <p>这张照片拍摄于 <%= link_to @photo.school.title, school_path(@photo.school.id) %></p>
<% end -%>
</div>

<div class="span-7 prepend-1" style="text-align:left;">
	<%= link_to "上一张", photo_path(@photo.next) if @photo.id != Photo.last.id %>&nbsp;
</div>
<div class="span-7 last apend-1" style="text-align:right;">
	<%= link_to "下一张", photo_path(@photo.previous) if @photo.id != 1 %>
</div>

<div style="text-align:center;">	
	<%= link_to image_tag(@photo.public_filename(:medium), :alt => @photo.title, :title=>"点击浏览下一张"), photo_path(@photo.previous) %>
	<p><%= link_to "查看原始图片", @photo.public_filename %></p>
</div>

<div><%= simple_format @photo.description %></div>

<% if @photo.editable_by?(current_user) -%>
  <p style="text-align:right;">分享到: <%= link_to "我参加的活动", share_event_photo_url(@photo) %> | 
    <%= link_to "我去过的学校", share_school_photo_url(@photo) %>, 操作: <%= link_to "编辑照片信息", edit_photo_url(@photo) %>, <%= link_to "删除", photo_url(@photo), :method => 'delete', :confirm => "确定要删除么？" %></p>
<% end -%>

<h3 class="nt">用户留言<%= title_suffix %></h3>
<div class="span-15 prepend-1 last">
	<% if @comments.blank? -%>
  	<p>还没有回复，你要不要加盖一楼</p>
	<% end -%>
	<% @comments.each do |comment| -%>
	<div class="span-2">
		<%= avatar_for comment.user, "large" %>
	</div>
	<div class="span-13 last">		
		<div class="span-11">
			<div class="comment_label">
				<span class="tip"><%= link_to comment.user.login, user_path(comment.user) %> 回复于: <%= show_date comment.created_at %></span>
			</div>
		</div>
		<div class="span-2 last">
			<% if comment.editable_by?(current_user) -%>
			<span class="comment_label">
				<%= link_to "修改", photo_edit_comment_path(@photo, comment) %>
				<%= link_to "删除", photo_comment_path(@photo, comment), :method => 'delete', :confirm => "您确定要删除么？" %>
			</span>
			<% end -%>
		</div>
		<div class="span-13"><%= comment.content_html %></div>
	</div>
	<% end -%>
</div>

<% if logged_in? -%>
	<h3 class="nt">你的留言</h3>
  <% form_for :comment, :url => photo_comments_path(:photo_id => @photo.id) do |f| -%>
    <%= render :partial => 'photo_comments/form', :object => f, :locals => {:title => "Re:#{@photo.title}"} %>
    <p><%= submit_tag "发布评论" %></p>
  <% end -%>
<% else -%>
  <%= link_to "登录", login_url %>后你也可以发表评论或留言
<% end -%>